<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改产品规格')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-post-edit" th:object="${size}">
			<input id="sizeId" name="sizeId" type="hidden" th:field="*{sizeId}"/>
			<div class="form-group">
				<label class="col-sm-3 control-label">规格名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="sizeName" id="sizeName" th:field="*{sizeName}" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">显示顺序：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="sizeSort" id="sizeSort" th:field="*{sizeSort}" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">产品规格描述：</label>
				<div class="col-sm-8">
					<textarea id="sizeDesc" name="sizeDesc" class="form-control">[[*{sizeDesc}]]</textarea>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "product/size";
		
		$("#form-post-edit").validate({
			onkeyup: false,
			rules:{
				sizeName:{
					remote: {
		                url: ctx + "product/size/checkSizeNameUnique",
		                type: "post",
		                dataType: "json",
		                data: {
		                	"sizeId": function() {
							    return $("input[name='sizeId']").val();
							},
		                	"sizeName" : function() {
		                        return $.common.trim($("#sizeName").val());
		                    }
		                },
		                dataFilter: function(data, type) {
		                	return $.validate.unique(data);
		                }
		            }
				},
				sizeSort:{
					digits:true
				},
			},
			messages: {
		        "sizeName": {
		            remote: "产品规格名称已经存在"
		        }
		    },
		    focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/edit", $('#form-post-edit').serialize());
	        }
	    }
	</script>
</body>
</html>
